<template>
  <div class="header">
      <el-dropdown>
        <i class="el-icon-setting" style="margin-right: 15px"></i>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item @click.native="exit()">退出</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
      <span style="margin-right: 100px;">{{nickname}}</span>
  </div>
</template>

<script>
export default {
  name:"headers",
  data() {
    return {
      nickname:""
    }
  },
  methods: {
    exit(){
      localStorage.removeItem('token')
      localStorage.removeItem('user')
      this.$router.push('/login')
      this.$message({
        message:'退出成功',
        type:'success'
      })
    }
  },
  created(){
      const user_str = localStorage.getItem('user')
      const user = JSON.parse(user_str)
      this.nickname = user.nickname
  }
};
</script>

<style lang="scss" scoped>
  .header{
    height: 60px;
    background: #303643;
    text-align: right; 
    font-size: 12px;
    line-height: 60px;
    color: #fff;

    // padding-right: 100px;
  }
  .el-icon-setting{
    cursor: pointer;
    color: #fff;
  }
</style>